﻿using System;
using System.ServiceModel;
using CommonDataContracts;
using System.Net.Security;

namespace BacteriumObserver
{
    
    [ServiceContract(ProtectionLevel = ProtectionLevel.None)]
    [ServiceKnownType(typeof(BacteriumAction))]
    public interface IBacteriumObserver
    {
        /// <summary>
        /// Registers the caller with the domain unless it is already registered.
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <param name="b">Snapshot of the caller bacterium's properties.</param>
        [OperationContract(IsOneWay = true)]        
        void RegisterWithDomain(String endpoint, BacteriumSnapshot b);

        /// <summary>
        /// Updates observer's snapshot of the caller bacterium if registered.
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <param name="name">Name of the property to be updated.</param>
        /// <param name="value">New value of the property</param>
        [OperationContract(IsOneWay = true)]
        void UpdateBacteriumProperty(String endpoint, String name, String value);

        /// <summary>
        /// Returns a neutral bacterium if any. 
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <returns>Endpoint address of the first found neutral bacterium in the domain, or an empty string if none found</returns>
        [OperationContract]
        String GetNeutralBacterium(String endpoint);

        /// <summary>
        /// Examines the team balance between caller bacterium's allies and all the enemies combined. This call takes account of a tactical aspect, i. e. how many enemies can act.
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <returns>True if the allies have advantage, false otherwise.</returns>
        [OperationContract]
        Boolean GetTeamBalance(String endpoint);

        /// <summary>
        /// Returns the endpoint of a weakest enemy (if any) in the domain.
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <returns>Endpoint address of the enemy with the least power of an empty string if there is none.</returns>
        [OperationContract]
        String GetWeakestEnemy(String endpoint);

        /// <summary>
        /// Compares cumulative powers of the allies against all of the enemies combined and returns result.
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <returns>True if the allies have advantage, false otherwise.</returns>
        [OperationContract]
        Boolean GetPowerRatio(String endpoint);

        /// <summary>
        /// Returns the endpoint of a weakest ally (if any) in the domain.
        /// </summary>
        /// <param name="endpoint">Endpoint address of the caller bacterium.</param>
        /// <returns>Endpoint address of the ally with the least power of an empty string if there is none.</returns>
        [OperationContract]
        String GetWeakestAlly(String endpoint);
        

    }  
    
}
